/*******************************************************************************
 ** Name: db.cpp                                                       **
 ** Description:              **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $GOVTSANCT_WIKI/License-software.                **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $HOME/LICENSE.                      **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 **                                                                           **
 ** Ref: $HeadURL: https://govtsanct.svn.codeplex.com/svn/trunk/lib/db.cpp $
 ******************************************************************************/

// $Id: db.cpp 63608 2011-11-24 07:07:02Z unknown $
// Last Modified by $Author: unknown $

#include "db.hpp"

///////////////////////////////[ ServerCfg
DataBase::DataBase(const std::string & s)
{

}

///////////////////////////////[ ServerCfg
int
ServerCfg::Parse()
{
    DBGFUNC();

    char buff[256];
    char a[64], v[64];
    //std::string buff;

    while (!conf.eof()) {
        conf.getline(buff,256);
        if (buff[0] == '#' || buff[0] == '\n' || buff[0] == '\r' || buff[0] == '\0')
            continue;

        sscanf(buff,"%s = %s",a,v);
        debug::log->out(LOG_DEBUG,"Adding %s = %s",a,v);
        avpairs[a] = v;
    }

    return avpairs.size();
}

bool
ServerCfg::Init()
{
    DBGFUNC();

    conf.open(fl, std::ios::in);
    if (conf.good()) {
        bInitialized = true;
        return true;
    }

    return false;
}

ServerCfg::ServerCfg(const std::string & s)
{
    debug::log->out(LOG_DEBUG,"Using conf: %s",s.c_str());
    fl = s;
    bInitialized = false;
}

